import { FormInstance } from "element-plus";

// 表单重置
export function resetForm(formEl: FormInstance|undefined ) :void{
  if(formEl){
    formEl.resetFields()
  }
}

/**
 * 判断是否为空
 * @param value
 */
export function isEmpty(value): boolean{
  if(value === null || value === undefined){
    return true;
  }
  if (typeof value === 'number' || typeof value === 'boolean') {
    return false;
  }
  if (typeof value === 'string') {
    return (value as string).trim().length === 0;
  }

  if (Array.isArray(value)) {
    return value.length === 0;
  }

  if (typeof value === 'object') {
    return Object.keys(value).length === 0;
  }

  return false;
}

/**
 *
 * @param value 不为空
 */
export function isNotEmpty(value):boolean{
  return !isEmpty(value)
}
